/*
 * Created by SharpDevelop.
 * User: GZamor1
 * Date: 9/11/2007
 * Time: 11:25 AM
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */

using System;
using System.Collections.Generic;
using System.Xml;
using System.Xml.XPath;
using System.Text.RegularExpressions;
using MediaPortal.GUI.Library;
namespace OnlineVideos.Sites
{
	/// <summary>
	/// Description of CnnUtil.
	/// </summary>
	public class MsnbcUtil: SiteUtilBase
	{
		
		public override string getUrl(OnlineVideos.GUIOnlineVideos.VideoInfo video, OnlineVideos.GUIOnlineVideos.SiteSettings foSite)
		{
            return String.Format("http://www.msnbc.msn.com/default.cdnx/id/{0}/displaymode/1157/?t=.flv", video.VideoUrl);
		}
		public override string getSiteId()
		{
			return "28";
		}
        public override List<OnlineVideos.GUIOnlineVideos.VideoInfo> getVideoList(string fsUrl)
        {
            Log.Info("MsnbcUtil.getVideoList invoked with param:" + fsUrl);
            List<RssItem> loRssItemList = getRssDataItems(fsUrl);
            List<GUIOnlineVideos.VideoInfo> loVideoList = new List<GUIOnlineVideos.VideoInfo>();
            GUIOnlineVideos.VideoInfo video;
            Regex idRegex = new Regex("#(.*)");
            foreach (RssItem rssItem in loRssItemList)
            {
                video = new GUIOnlineVideos.VideoInfo();
                video.Description = rssItem.description;
                video.ImageUrl = rssItem.mediaThumbnail;
                video.Title = rssItem.title;
                video.Length = rssItem.contentList[0].duration;
                video.VideoUrl = idRegex.Match(rssItem.guid).Groups[1].Value;
                loVideoList.Add(video);
            }
            return loVideoList;
        }
	}
}
